﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Gem_Tools_Entity.Gem_Tools;
using Gem_Tools_Controller.Gem_Tools;
using Gem_Tools_Utility;
using Gem_Tools;

namespace GE_Management_Tool.Planning
{
    public partial class frmA0019_Add_Multiple_Artists : frmBase
    {
        IList<CStaff> m_lsStaff;

        public frmA0019_Add_Multiple_Artists()
        {
            InitializeComponent();
            CCommon_Function.Format_All(this);
            this.grvStaff.OptionsBehavior.Editable = true;
        }

        private void frmA0019_Add_Multiple_Artists_Load(object sender, EventArgs e)
        {
            try
            {
                m_lsStaff = new List<CStaff>();
                CStaff_Controller v_objCtrlSTaff = new CStaff_Controller();
                m_lsStaff = v_objCtrlSTaff.A0019_sp_sel_List_Staff_Not_In_Project_Staff_By_Project_ID(CConfig.g_intGem_Tools_Current_Project, CUtility.Convert_To_Int32(EStaff_Type.Artist));
                cStaffBindingSource.DataSource = m_lsStaff;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK);
            }
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (CStaff v_staff in m_lsStaff)
                {
                    if (v_staff.Selected == true)
                    {
                        CProject_Staff v_objProj_Staff = new CProject_Staff();

                        v_objProj_Staff.Project_ID = CConfig.g_intGem_Tools_Current_Project;
                        v_objProj_Staff.Staff_ID = v_staff.Auto_ID;

                        CProject_Staff_Controller v_ctrlStaff = new CProject_Staff_Controller();
                        v_objProj_Staff.Auto_ID = v_ctrlStaff.Insert_Project_Staff(v_objProj_Staff);
                    }
                }
                XtraMessageBox.Show("Insert Success !");
                this.Close();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK);
            }
        }
    }
}